package com.samp.solr.analysis;

import java.util.Map;

import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.apache.lucene.util.AttributeFactory;

/**
 * 根据标点符号进行分词。
 *
 */
public class PunctuationTokenizerFactory extends TokenizerFactory {
	
	private final String punctuations;
	
	  public PunctuationTokenizerFactory(Map<String,String> args) {
	    super(args);
	    punctuations = get(args, "punctuations");
	    //上面get取值后，会删除原值，所以最后args会为空。
	    if (!args.isEmpty()) {
	      throw new IllegalArgumentException("Unknown parameters: " + args);
	    }
	  }

	@Override
	public Tokenizer create(AttributeFactory factory) {
		return new PunctuationTokenizer(factory, punctuations);
	}

}
